<?php
namespace app\back\controller;
use app\model\Admin;

class Index extends BaseAdmin{



    function login_act(){
        $params=request()->param();
        //var_dump($params);
        if($params['name']==false){
            $this->error_tip("用户名不能为空");
        }
        if($params['password']==false){
            $this->error_tip("密码不能为空");
        }
        $AdminModel=new Admin();
        $a_arr=$AdminModel->get_info_by_name($params['name']);
        if($a_arr==false){
            return  $this->error_tip("用户名不存在");
        }elseif($a_arr['password']==md5($params['password'])){
            $this->set_session_admin($a_arr['id'],$a_arr['name']);
            return $this->success_tip("登陆成功",url("back/Admin/wellcome"));
        }else{
            return $this->error_tip("用户跟密码不一致");
        }


    }
    function login_html(){
        return $this->fetch("./login");
    }

    function check_admin(){

    }

    function login_out(){
        session_destroy();
        header("location:".url("/back/Index/login_html"));
    }







}
